#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>

int compare(const void* p1, const void* p2)
{
    return (*(int*)p1 - *(int*)p2);
}
int deleteGreatestValue(int** grid, int gridSize, int* gridColSize)
{
    int tmp = 0;
    for (int i = 0; i < gridSize; i++)
    {
        qsort(grid[i], *gridColSize, sizeof(int), compare);
    }
    for (int j = *gridColSize - 1; j >= 0; j--)
    {
        int max = 0;
        for (int i = 0; i < gridSize; i++)
        {
            if (grid[i][j] > max)
                max = grid[i][j];
        }
        tmp += max;
    }
    return tmp;
}



